﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using csharp.rad.general;
using ComponentFactory.Krypton.Toolkit;

namespace csharp.rad.GOVhotel
{
    public partial class Aparto : KryptonForm
    {
        Database myDBase;

        public Aparto(Database myDBase)
        {
            InitializeComponent();
            this.myDBase = myDBase;
        }

        private void cmdOK_Click(object sender, EventArgs e)
        {
            int nmApto =(int) ((numApto1.Value * 1000) + (numApto2.Value * 100) + numApto4.Value); 
            Apartamento regApto = new Apartamento(myDBase);
            regApto.Apto = nmApto;
            if (opçBlindexS.Checked) regApto.Blindex = "S";
            else regApto.Blindex = "N";
            int dbRet = regApto.SetBlindex();
            if (dbRet != 0)
            {
                MessageBox.Show("Favor avisar a RamaSoft" + "\n"
                    + "referência: ApartoOK" + "\n" + regApto.MsgErro,
                    "Erro no acesso ao Banco de Dados", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            cmdOK.Visible = false;
            infoOK.Visible = true;
            Pulso.Enabled = true;
        }

        private void Pulso_Tick(object sender, EventArgs e)
        {
            Pulso.Enabled = false;
            infoOK.Visible = false;
        }

        private void numApto_ValueChanged(object sender, EventArgs e)
        {
            cmdOK.Visible = true;
        }
    }
}
